<template>
	<view class="content">
		<view class="listItem">
			<view style="display: flex;flex-direction: column;justify-content: center;align-items: center;padding-bottom: 40upx;border-bottom: 1px solid #DDDDDD;">
				<image style="width: 128upx;height: 128upx;" src="../../static/pay/succ.png" mode="scaleToFill"></image>
				<text style="font-size: 40upx;color: #26D19C;">订单支付成功</text>
			</view>
			
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">用户名:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{userInfo.nickName}}</text>
			</view>
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">名称:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.name}}</text>
			</view>
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">订单金额:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.usdt}}USDT/{{item.fil}}FIL</text>
			</view>
			<view style="display: flex;justify-content: space-between;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">购买份额:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{buyNum}}份</text>
			</view>
			<view v-if="current!=3" style="display: flex;justify-content: space-between;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">矿工算力:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.computePower}}</text>
			</view>
			<view v-if="current==3"  style="display: flex;justify-content: space-between;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">年化率</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.nhl}}%</text>
			</view>
			<view style="display: flex;justify-content: space-between;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">合约周期:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.hyzq}}天</text>
			</view>
			<view v-if="current!=3" style="display: flex;justify-content: space-between;align-items: center;margin-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;width: 30%;">封存周期:</text>
				<text style="font-size: 30upx;color: #656565;width: 70%;">{{item.fczq}}天</text>
			</view>
			<view style="display: flex;justify-content: flex-end;align-items: center;margin-top: 20upx;border-top: 1px solid #DDDDDD;padding-top: 20upx;">
				<text style="font-size: 30upx;color: #656565;">合计：{{item.usdts}}USDT/{{item.fils}}FIL</text>
			</view>
		</view>
	</view>
</template>

<script>
	import ypNumberBox from "@/components/yp-number-box/yp-number-box.vue"
	import ssPaymentPassword from '@/components/sanshui-payment-password'
	import {
		mapState
	} from 'vuex';
	export default {
		components: {
			ypNumberBox,
			ssPaymentPassword
		},
		data() {
			return {
				token:'',
				buyNum:1,
				mode: 0,
				item:{}
			}
		},
		onLoad(option) {
			var that=this;
			that.item_id = option.id;
			that.current=option.current;
			that.buyNum=option.buyNum
		},
		computed: {
			...mapState(['hasLogin','userInfo'])
		},
		onShow(){
			var that=this;
			that.checkToken();
		},
		methods: {
			numberChange:function(data){
				var that = this;
				that.buyNum = data[1];
				that.$set(that.item,'usdts',Number(that.buyNum * that.item.usdt));
				that.$set(that.item,'fils',Number(that.buyNum * that.item.fil));
			},
			
			
			checkToken(){
				var that=this;
				 uni.getStorage({
				    key: 'token',
				    success: function (res) {
						that.token=res.data;
						that.getDetail(res.data);
				    },
					fail:function(error){
						uni.navigateTo({
							url: `/pages/login/login`
						})
					}});
			},
			//获取详情 1,2 是 矿机 3是存币生息
			getDetail(token){
				
				var that=this;
				var url='';
				if(that.current!=3){
					url = that.serverUrl2 + '/biz/api/v1/cp/kj/'+that.item_id
				}
				else{
					url = that.serverUrl2 +'/biz/api/v1/cp/cbsx/'+that.item_id
				}
				
				uni.request({
						url: url,
						method: "GET",
						header: {
							'content-type': 'application/json',
							'Authorization': 'Bearer '+token
						},
						success: (res) => {
							if (res.data.code == 200) {
								console.log(res.data);
								that.item=res.data.data;
								that.$set(that.item,'usdts',Number(that.buyNum * that.item.usdt));
								that.$set(that.item,'fils',Number(that.buyNum * that.item.fil));
							}
						},
						fail: (error) => {
							console.log(error);
						}
					})
			},
			
			
		}
	}
</script>
<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		// align-items: center;
		// justify-content: center;
		background-color: #F2F2F2;
	}
	.listItem {
		display: flex;
		flex-direction: column;
		margin-top: 40upx;
		width: 82%;
		margin-left: 4%;
		margin-right: 4%;
		border-radius: 10upx;
		background-color: #FFFFFF;
		padding: 5%;
		margin-bottom: 40upx;
		
	}
</style>
